package com.itheima;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.heima.common.aliyun.GreenImageScan;
import com.heima.common.aliyun.GreenTextScan;
import com.heima.file.service.FileStorageService;
import com.heima.wemedia.WemediaApplication;
import org.checkerframework.checker.units.qual.A;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@SpringBootTest(classes = WemediaApplication.class)
@RunWith(SpringRunner.class)
public class test {

    @Autowired
    private GreenImageScan greenImageScan;

    @Autowired
    private GreenTextScan greenTextScan;

    @Autowired
    private FileStorageService fileStorageService;

    /**
     * 图片检测
     */
    @Test
    public void test1() throws Exception {
        String url = "http://192.168.58.138:9000/leadnews/2023/03/12/81eb58b1-5b54-4478-a478-cfcee5963ff2.Snipaste_2022-12-01_11-20-15.png";
        byte[] bytes = fileStorageService.downLoadFile(url);
        List<byte[]> list = new ArrayList<>();
        list.add(bytes);
        Map map = greenImageScan.imageScan(list);
        System.out.println(map);
    }

    @Test
    public void test2() throws Exception {
        Map map = greenTextScan.greeTextScan("直降9万！冰毒12万买东风雪铁龙C6，天底下真有这样的好事？这里面有没有套路？消费者去了是捡大便宜，还是当大冤种？ 事情原由大家已经很清楚了，几乎也是3月份目前全国车市最热点新闻，即湖北省开启史上最强购车优惠季，尤其以东风系中的法系合资品牌标致、雪铁龙为代表。冲上热搜引发热议的是，算上降价和湖北省政企补贴后，雪铁龙C6部分车型直接降价9万\n");
        System.out.println(map);
        String suggestion = (String) map.get("suggestion");
        System.out.println(suggestion);
    }
}
